-
Notifications
You must be signed in to change notification settings - Fork 241
[cxx-interop] Add documentation about calling ctor or static factory of SWIFT_SHARED_REFERENCE types as Swift Initializer #1079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…of SWIFT_SHARED_REFERENCE types as Swift Initializer
b8a4ffc
to
d61979c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @egorzhdan
CC: @j-hui |
CC: @ravikandhadai |
documentation/cxx-interop/index.md
Outdated
In this case, Swift will import the static `make` function as a Swift initializer: | ||
|
||
```swift | ||
let object = SharedObject(id: 42) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The id
label shouldn't be there, i.e.,
let object = SharedObject(id: 42) | |
let object = SharedObject(42) |
But I think you should give more examples here. Also, doSomething()
isn't really necessary here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@j-hui Let's add more examples of using the SWIFT_NAME
technique in a follow-up patch. We can experiment with this feature on some adopter projects or dummy examples before documenting.
let object = SharedObject(42) | ||
``` | ||
|
||
Note that if a C++ constructor and a user-annotated static factory (using `SWIFT_NAME`) have identical parameter signatures, Swift favors the static factory when resolving initializer calls. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@j-hui @Xazax-hun : I'm torn between keeping this note and deleting it because it seems like I'm sharing too much information. What do you think?
including this in PR-1106 |
Update C++ interop documentation to describe Swift initializer support for C++
SWIFT_SHARED_REFERENCE
type's constructors and static factories annotated withSWIFT_NAME
.